package com.sz.mes.excel.model;

import java.util.Date;
import java.lang.Double;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.HeadStyle;
import com.alibaba.excel.enums.poi.FillPatternTypeEnum;
import com.diboot.core.util.D;
import com.diboot.core.util.V;
import com.diboot.file.excel.BaseExcelModel;
import com.diboot.file.excel.annotation.ExcelBindDict;
import com.diboot.file.excel.annotation.ExcelBindField;
import com.diboot.file.excel.annotation.ExcelOption;
import com.fasterxml.jackson.annotation.JsonFormat;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;

import com.sz.mes.entity.PurchaseOrder;

/**
 * 采购订单 导入model定义
 *
 * @author hem
 * @version 1.0
 * @date 2024-01-10
 * Copyright © szhs
 */
@Getter
@Setter
@ExcelIgnoreUnannotated
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 1)
public class PurchaseOrderImportModel extends BaseExcelModel {

    /**
     * 来源单据号
     */
    @Length(max = 100, message = "来源单据号长度应小于100")
    @ExcelProperty(value = "来源单据号")
    private String sourceNum;
    /**
     * 来源单据行号
     */
    @Length(max = 100, message = "来源单据行号长度应小于100")
    @ExcelProperty(value = "来源单据行号")
    private String sourceNumRow;
    /**
     * 行状态
     */
    @Length(max = 100, message = "行状态长度应小于100")
    @ExcelProperty(value = "行状态")
    private String rowState;
    /**
     * 计划号
     */
    @Length(max = 255, message = "计划号长度应小于255")
    @ExcelProperty(value = "计划号")
    private String planNum;
    /**
     * 料号
     */
    @Length(max = 100, message = "料号长度应小于100")
    @ExcelProperty(value = "料号")
    private String productNum;
    /**
     * 料品名称
     */
    @Length(max = 255, message = "料品名称长度应小于255")
    @ExcelProperty(value = "料品名称")
    private String productName;
    /**
     * 料品规格
     */
    @Length(max = 255, message = "料品规格长度应小于255")
    @ExcelProperty(value = "料品规格")
    private String specification;
    /**
     * 采购订单行.采购单位
     */
    @Length(max = 100, message = "采购订单行.采购单位长度应小于100")
    @ExcelProperty(value = "采购订单行.采购单位")
    private String unit;
    /**
     * 需求数量
     */
    @ExcelProperty(value = "需求数量")
    private Integer requireNum;
    /**
     * 确认数量
     */
    @ExcelProperty(value = "确认数量")
    private Integer factNum;
    /**
     * 单据编号
     */
    @Length(max = 100, message = "单据编号长度应小于100")
    @ExcelProperty(value = "单据编号")
    private String receiptNum;
    /**
     * 行号
     */
    @Length(max = 100, message = "行号长度应小于100")
    @ExcelProperty(value = "行号")
    private String rowNum;
    /**
     * 采购业务员
     */
    @Length(max = 100, message = "采购业务员长度应小于100")
    @ExcelProperty(value = "采购业务员")
    private String purchasePerson;
    /**
     * 业务日期
     */
    @DateTimeFormat(D.FORMAT_DATE_Y4MD)
    @JsonFormat(pattern = D.FORMAT_DATE_Y4MD)
    @ExcelProperty(value = "业务日期")
    private Date businessDate;
    /**
     * 交期
     */
    @DateTimeFormat(D.FORMAT_DATE_Y4MD)
    @JsonFormat(pattern = D.FORMAT_DATE_Y4MD)
    @ExcelProperty(value = "交期")
    private Date deliveryDate;
    /**
     * 申请到货日期
     */
    @Length(max = 100, message = "申请到货日期长度应小于100")
    @ExcelProperty(value = "申请到货日期")
    private String arrivalDate;
    /**
     * 供应商简称
     */
    @Length(max = 100, message = "供应商简称长度应小于100")
    @ExcelProperty(value = "供应商简称")
    private String supplierName;
//    /**
//     * excel内容
//     */
//    @Length(max=100, message="excel内容长度应小于100")
//    @ExcelProperty(value = "excel内容")
//    private String excelData;


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PurchaseOrderImportModel purchaseOrderImportModel = (PurchaseOrderImportModel) o;
        Boolean sourceNumSame = true;
        Boolean sourceNumRowSame = true;
        Boolean rowStateSame = true;
        Boolean planNumSame = true;
        Boolean productNumSame = true;
        Boolean productNameSame = true;
        Boolean specificationSame = true;
        Boolean unitSame = true;
        Boolean requireNumSame = true;
        Boolean factNumSame = true;
        Boolean receiptNumSame = true;
        Boolean rowNumSame = true;
        Boolean purchasePersonSame = true;
        Boolean businessDateSame = true;
        Boolean deliveryDateSame = true;
        Boolean arrivalDateSame = true;
        Boolean supplierNameSame = true;

        if (sourceNum != null) {
            sourceNumSame = sourceNum.equals(purchaseOrderImportModel.sourceNum);
        }
        if (sourceNumRow != null) {
            sourceNumRowSame = sourceNumRow.equals(purchaseOrderImportModel.sourceNumRow);
        }
        if (rowState != null) {
            rowStateSame = rowState.equals(purchaseOrderImportModel.rowState);
        }
        if (planNum != null) {
            planNumSame = planNum.equals(purchaseOrderImportModel.planNum);
        }
        if (productNum != null) {
            productNumSame = productNum.equals(purchaseOrderImportModel.productNum);
        }
        if (productName != null) {
            productNameSame = productName.equals(purchaseOrderImportModel.productName);
        }
        if (specification != null) {
            specificationSame = specification.equals(purchaseOrderImportModel.specification);
        }
        if (unit != null) {
            unitSame = unit.equals(purchaseOrderImportModel.unit);
        }
        if (requireNum != null) {
            requireNumSame = requireNum.equals(purchaseOrderImportModel.requireNum);
        }
        if (factNum != null) {
            factNumSame = factNum.equals(purchaseOrderImportModel.factNum);
        }
        if (receiptNum != null) {
            receiptNumSame = receiptNum.equals(purchaseOrderImportModel.receiptNum);
        }
        if (rowNum != null) {
            rowNumSame = rowNum.equals(purchaseOrderImportModel.rowNum);
        }
        if (purchasePerson != null) {
            purchasePersonSame = purchasePerson.equals(purchaseOrderImportModel.purchasePerson);
        }
        if (businessDate != null) {
            businessDateSame = businessDate.equals(purchaseOrderImportModel.businessDate);
        }
        if (deliveryDate != null) {
            deliveryDateSame = deliveryDate.equals(purchaseOrderImportModel.deliveryDate);
        }
        if (arrivalDate != null) {
            arrivalDateSame = arrivalDate.equals(purchaseOrderImportModel.arrivalDate);
        }
        if (supplierName != null) {
            supplierNameSame = supplierName.equals(purchaseOrderImportModel.supplierName);
        }

        return sourceNumSame && sourceNumRowSame && rowStateSame && planNumSame && productNumSame && productNameSame
                && specificationSame && unitSame && requireNumSame && factNumSame && receiptNumSame && rowNumSame
                && purchasePersonSame && businessDateSame && deliveryDateSame && arrivalDateSame && supplierNameSame;
    }


    @Override
    public int hashCode() {
        return Objects.hash(sourceNum, sourceNumRow, rowState, planNum, productNum, productName, specification, unit,
                requireNum, factNum, receiptNum, rowNum, purchasePerson, businessDate, deliveryDate, arrivalDate,
                supplierName);
    }
}
